package com.hezhou.jenkins.my_jenkins_test.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * ---------------------------
 * (Person) 用户
 * ConfigurationProperties 将本类中的值和配置文件中相关的值做绑定
 * prefix  配置文件中哪个文件进行一一映射
 * 只有这个组件时容器中的组件 才能提供@ConfigurationProperties功能
 * ---------------------------
 * 加载配置文件的值
 * @Author: [hezhou]
 * @Date: 2020/4/8
 * @Version: [1.0.1]
 * ---------------------------
 */
@Component
@PropertySource(value = "classpath:person.properties")
@ConfigurationProperties(prefix = "person")
@Validated
public class Person {

//    @Value("${person.last-name}")
//    @Email
    private String lastName;

//    @Value("#{22*2}")
    private Integer age;

//    @Value("${person.boss}")
    private Boolean boss;

//    @Value("${person.birth}")
    private Date birth;

    private Map<String,Object> maps;

//    @Value("${person.lists}")
    private List<Object> lists;

    private Dog dog;

    @Override
    public String toString() {
        return "Person{" +
                "lastName='" + lastName + '\'' +
                ", age=" + age +
                ", boss=" + boss +
                ", birth=" + birth +
                ", maps=" + maps +
                ", lists=" + lists +
                ", dog=" + dog +
                '}';
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Boolean getBoss() {
        return boss;
    }

    public void setBoss(Boolean boss) {
        this.boss = boss;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public Map<String, Object> getMaps() {
        return maps;
    }

    public void setMaps(Map<String, Object> maps) {
        this.maps = maps;
    }

    public List<Object> getLists() {
        return lists;
    }

    public void setLists(List<Object> lists) {
        this.lists = lists;
    }


    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }
}
